/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014-2016 abel533@gmail.com
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.sinosoft.comm.entity;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.io.Serializable;
import java.util.Date;


public class BaseEntity implements Serializable{
	
	private static final long serialVersionUID = 1L;
	@Id
    @Column(name = "Id")
    public String id;
	@ApiModelProperty(hidden = true)
    @Column
    public Integer delFlag;
	@ApiModelProperty(hidden = true)
    @Column
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    public Date createTime;
	@ApiModelProperty(hidden = true)
    @Column
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
    public Date updateTime;
	@ApiModelProperty(hidden = true)
    @Column
    public String createUser;
	@ApiModelProperty(hidden = true)
    @Column
    public String updateUser;
    
    
    
    
    
    public String getCreateUser() {
		return createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	 /**   
	 * @Title: serialize   
	 * @Description: TODO(Fastjson的SerializerFeature序列化属�?  )
	 *  QuoteFieldNames—�?��??-输出key时是否使用双引号,默认为true
	 * 	WriteMapNullValue—�?��?�是否输出�?�为null的字�?,默认为false
	 * 	WriteNullNumberAsZero�?-数�?�字段如果为null,输出�?0,而非null
	 * 	WriteNullListAsEmpty—�?�List字段如果为null,输出为[],而非null
	 * 	WriteNullStringAsEmpty—字符类型字段如果为null,输出为�?��??,而非null
	 * 	WriteNullBooleanAsFalse–Boolean字段如果为null,输出为false,而非null
	 * @param: @param object
	 * @param: @param features
	 * @param: @return      
	 * @return: String  
	 * @throws   
	 */
	public static <T> String serialize(T object,SerializerFeature... features) {
	     return JSON.toJSONString(object,features);
	 }
	
	public String toString(SerializerFeature... features){
		return  serialize(this,features);
	}

	@Override
	public String toString(){
		return serialize(this);
	}
}
